package com.example.demo.controller;

import com.example.demo.common.Result;
import com.example.demo.entity.User;
import com.example.demo.entity.log;
import com.example.demo.mapper.LogMapper;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.annotation.Resources;
import java.util.Date;

@RestController
@RequestMapping("/log")
public class LogController {
    @Resource
    LogMapper logMapper;

    @PostMapping
    public Result<?> logExecute(@RequestBody User user){
        Date date=new Date();
        date.setTime(date.getTime()+28800000);
        log logWriter=new log();
        logWriter.setDate(date);
        logWriter.setIdentity(user.getIdentity());
        logWriter.setName(user.getName());
        logWriter.setUserid(user.getId());
        logMapper.insert(logWriter);
        return Result.success(logWriter);
    }
}
